

     import { $t } from '@/hooks/use-i18n'
     <!-- 推送虚拟组织目录 -->
<template>
</template>

<script>
import selectDepartment from '@/components/upCascadeInformation/selectDepartment.vue'
export default {
  data() {
    return {
      form: {},
      orgList: [], // 需要推送的部门id
      dialogVisible: false,
      successfulCallback: null
    }
  },
  components: {
    selectDepartment
  },
  // computed: {},
  mounted() {},
  // created(){ // document.title = this.type === 2 ? '设置手机号' : '绑定手机号' },
  methods: {
    async getOrgList() {
      const res = await this.$api.findAll('northPlatform/orgCatalog', {
        northPlatformId: this.form.id // 向上级联平台id
      })
      if (res.code === 200) {
        this.orgList = res.data || [] // 需要推送的部门id
        this.dialogVisible = true
      }
    },
    setOrgList(orgList = []) {
      this.orgList = orgList // 需要推送的部门id
    },
    show(item) {
      return new Promise((resolve, reject) => {
        this.successfulCallback = resolve
        this.form = { ...item }
        this.getOrgList()
      })
    },
    async onSubmit() {
      const orgCatalogPush = this.form.orgCatalogPush
      if (orgCatalogPush === 1 && this.orgList.length === 0) {
        return this.$message.error(
            this.$t('youHaveNotSelectedTheOrganizationToPush')
        )
      }
      const res = await this.$api.northPlatform.orgCatalogSave({
        northPlatformId: this.form.id, // 向上级联平台id
        orgCatalogPush: orgCatalogPush, // 是否推送虚拟组织目录（0否、1是）
        orgIdList: orgCatalogPush === 1 ? this.orgList.map((v) => v.id) : []
      })
      if (res.code === 200) {
        this.$message.success(this.$t('operationSuccessful'))
        this.successfulCallback(this.form)
        this.onClose()
      }
    },
    onClose() {
      this.dialogVisible = false
    }
  }
}
</script>
<style scoped lang="less" rel="stylesheet/less">


</style>

